|
|
||||||||||
|
Sometimes, you need to keep
track of special information and act differently depending on what position
the situation is in. After if() statements, a code string is placed within
curled brackets. The code will only be executed in cases when the argument
(the statement within the brackets) is correct. Let us look onto an example:
What the game engine will do when finding this part is to first look on the argument and check if it is true or not. In this case, it will try to find out if the value bound to "number" is equal to 3 or not. If it is true, the engine will execute the code placed within the curled brackets, in this case, doing nothing for 0.1 seconds (or rather 100 milliseconds). If "number" is not equal to three, nothing will happen. Sometimes, you might need to
check if the value is greater or smaller than needed by the use of ">"
and "<" signs (that by an strange coincidence, together with
the underline sign, make a sort of smiley that people use to look like
after searching for a stupid error for hours ">_<"). The
sign ">=" means "larger or equal to"
and it's equivalent "<=" means "smaller
or equal to". In follwing example, the code will only be executed
if "number" is smaller than three.
At other times, the code is only needed to be
executed only if a value is by no means equal to another. In those cases
we put an exclamation sign in front. The code will only be executed if
"number" is not equal to 3.
Another function that can be used is while( ). As you might hear the
name, it executes a function while certain conditions
are met. In this case, the script will run the command "sleep 100"
over and over as long as "number" is equal
to 3.
Congratulations, if you mastered this part, you can continue reading Lesson 2. |
||||||||||
| © Proud like a god (and a little Storm) | ||||||||||